<?php


namespace app\api\service;


use app\api\model\Admin;


class Sadmin
{
    private $admin=null;
    public function __construct()
    {
        $this->admin = new Admin();
    }

    /**
     * @param $uname 用户名
     * @param $passwd 密码
     * @return string 返回确认信息
     */
    public function chkLogin($uname,$passwd){
        $data= array();
        $data['name']=$uname;
        $data['password']=md5($passwd);
        $ress=null;
        $ress=$this->admin->where($data)->find();
        if (!null==$ress){
            session("uid",$ress["id"]);
            session("uname",$ress["name"]);
            return "登陆成功";
        }else{
            return "登录失败";
        }
    }
}